package aip2011.controller.rifugio.dettaglio;

import javax.servlet.http.HttpServletResponse;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.util.ResponseLocator;

import com.google.appengine.tools.admin.ConfirmationCallback.Response;


import aip2011.model.ImmagineRifugio;
import aip2011.service.ImmagineRifugioService;

public class ImageController extends Controller {

    
    private ImmagineRifugioService service=new ImmagineRifugioService();
  
    @Override
    public Navigation run() throws Exception {

        if(asKey("key")!=null)
        {
                HttpServletResponse response = ResponseLocator.get();
                byte[] bytes ;
                ImmagineRifugio data = service.getData(asKey("key"), asLong("v"));
                bytes = service.getBytes(data);
                response.getOutputStream().write(bytes);
                response.setContentType("image/JPEG");
                return null;
        }
        return null;
    }
}
